home *** CD-ROM | disk | FTP | other *** search
/ Komputer for Alle 2001 #11 / CD 11 (Black) - 2001.iso / FAVORG / FAVO_SRC.ZIP / TreeCtrlEdit.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2000-10-25  |  1.5 KB  |  77 lines

  1. // FAVORG Version 1.1
  2. // Copyright (c) 2000 Ziff Davis Media, Inc.
  3. // All rights reserved.
  4. // First Published in PC Magazine, US Edition, November 7, 2000.
  5. // Programmer: Patrick Philippot
  6.  
  7. #include "stdafx.h"
  8. #include "favorg.h"
  9. #include "TreeCtrlEdit.h"
  10.  
  11. #ifdef _DEBUG
  12. #define new DEBUG_NEW
  13. #undef THIS_FILE
  14. static char THIS_FILE[] = __FILE__;
  15. #endif
  16.  
  17. /////////////////////////////////////////////////////////////////////////////
  18. // CTreeCtrlEdit
  19.  
  20. CTreeCtrlEdit::CTreeCtrlEdit()
  21. {
  22.     m_hCurItem = NULL;
  23.     m_pTreeCtrl = NULL;
  24. }
  25.  
  26. CTreeCtrlEdit::~CTreeCtrlEdit()
  27. {
  28. }
  29.  
  30.  
  31. BEGIN_MESSAGE_MAP(CTreeCtrlEdit, CEdit)
  32.     //{{AFX_MSG_MAP(CTreeCtrlEdit)
  33.     //}}AFX_MSG_MAP
  34. END_MESSAGE_MAP()
  35.  
  36. /////////////////////////////////////////////////////////////////////////////
  37. // CTreeCtrlEdit message handlers
  38.  
  39. BOOL CTreeCtrlEdit::PreTranslateMessage(MSG* pMsg) 
  40. {
  41.     // Prevent early termination of program when
  42.     // the user hits the ENTER or the ESCAPE key
  43.     if((m_hCurItem != NULL) && (m_pTreeCtrl) && (pMsg->message == WM_KEYDOWN))
  44.     {
  45.         CString m_Test;
  46.  
  47.         switch(pMsg->wParam)
  48.         {
  49.             case VK_RETURN:
  50.                 GetWindowText(m_Test);
  51.                 m_pTreeCtrl->SetItemText(m_hCurItem, m_Test);
  52.                 break;
  53.  
  54.             case VK_ESCAPE:
  55.                 break;
  56.         }
  57.  
  58.         ::TranslateMessage(pMsg);
  59.         ::DispatchMessage(pMsg);
  60.  
  61.         return TRUE;
  62.     }
  63.     
  64.     return CEdit::PreTranslateMessage(pMsg);
  65. }
  66.  
  67. void CTreeCtrlEdit::SetCurItem(HTREEITEM hItem)
  68. {
  69.     m_hCurItem = hItem;
  70. }
  71.  
  72. void CTreeCtrlEdit::SetTreeCtrl(CTreeCtrl* pTreeCtrl)
  73. {
  74.     m_pTreeCtrl = pTreeCtrl;
  75. }
  76.  
  77.